// pages/ucenter/ucenter.js
const App = getApp()
Page({

    data: {
        show: false,
        userInfo: {}
    },
    bindGetUserInfo(e) {
        var userInfo = e.detail.userInfo;
        App.globalData.userInfo.nickName = userInfo.nickName
        App.globalData.userInfo.gender = userInfo.gender
        App.globalData.userInfo.avatarUrl = userInfo.gender
        
        this.setData({
            userInfo,
            show: true
        })
    },
    onLoad() {
        var that = this

        wx.getSetting({
            success(res) {
                if (res.authSetting['scope.userInfo']) { //判断用户是否授权
                    wx.getUserInfo({
                        success: function (res) {
                            var userInfo = res.userInfo

                            App.globalData.userInfo.nickName = userInfo.nickName
                            App.globalData.userInfo.gender = userInfo.gender
                            App.globalData.userInfo.avatarUrl = userInfo.gender

                            console.log(getApp().globalData.userInfo)
                            that.setData({
                                show: true,
                                userInfo
                            })
                        }
                    })
                }
            }
        })
    },



    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})